package ru.sstu.renju.javafx;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import ru.sstu.renju.config.Config;
import ru.sstu.renju.config.ConfigReader;
import ru.sstu.renju.config.Platform;
import ru.sstu.renju.javafx.renderers.FXRenderer;

/**
 * {@code Renju} class is entry point of JavaFX version of Renju application.
 *
 * @author denis_murashev
 * @since Renju 1.0
 */
public class Renju extends Application {

	/**
	 * Default cell size in pixels.
	 */
	public static final int CELL_SIZE = 40;

	@Override
	public void start(Stage primaryStage) throws Exception {
		Platform platform = new Platform(FXRenderer.class);
		Config config = new ConfigReader().getConfig(platform);
		primaryStage.setTitle(config.getBundle().getString("app.title"));
		FlowPane root = new FlowPane();
		root.setOrientation(Orientation.VERTICAL);
		final double gap = 5;
		root.setHgap(gap);
		root.setVgap(gap);
		root.setPadding(new Insets(gap));
		GameCanvas canvas = new GameCanvas(config);
		root.getChildren().add(canvas.getCanvas());
		root.getChildren().add(new ConfigPane(config, canvas).getConfigPane());
		primaryStage.setScene(new Scene(root));
		primaryStage.show();
	}

	/**
	 * @param args arguments
	 */
	public static void main(String[] args) {
		launch(args);
	}
}
